#include "device.h"
#include <optional>
#include <mutex>

blu::device& blu::default_device()
{
	static std::optional<blu::device> globalDefaultDevice;
	static std::mutex _mutex;

	_mutex.lock();
	if (!globalDefaultDevice)
		globalDefaultDevice =
			impl::implAccess::makeThroughImpl<device>(blu::impl::Device());
	_mutex.unlock();
	return globalDefaultDevice.value();
}
